Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Charge channel opening fee through lsp flow #1528

Merged
merged 5 commits into from
Nov 3, 2023

Conversation

holzeis
Copy link
Contributor

@holzeis holzeis commented Oct 26, 2023

This change was fairly simple with the new channel config flag accept_underpaying_htlcs 🎉. The main change is in this commit abb2feb

  • open channel fee + funding transaction is now shown on the payment which triggered the inbound channel creation
  • cleanup of all occurrences where we were using the order matching fee or jit channel fee invoice

resolves #843
fixes #1147
fixes #1366
fixes #1445

Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-10-26.at.08.48.12.mp4

Unrelated minor fixes that could get separated into a single PRs.

  • c89154c: The app does not need to maintain a pending intercepted htlc map.
  • 114fd52: We have to fail the payment backwards in case we do not get a pre-image
  • 643b329: Add an argument to optionally do not truncate the provided value. fixes Pnl is not shown fully #1521
  • 82a712f: Fix an invalid sql file

@holzeis holzeis self-assigned this Oct 26, 2023
@holzeis holzeis force-pushed the feat/jit-channel-fee-lsp-flow branch 3 times, most recently from e310274 to c684b7d Compare October 26, 2023 10:17
Copy link
Contributor

@bonomat bonomat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looking forward to having this in production :)

crates/ln-dlc-node/src/config.rs Show resolved Hide resolved
format!("Couldn't find channel for user_channel_id {user_channel_id}",)
})?;

if channel.channel_state == ChannelState::Open {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


I don't understand, why would you fail if the channel is already open?
Wouldn't that prevent you from receiving payments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because then it is already been paid for.

ChannelReady -> OpenUnpaid
PaymentClaimable -> Open

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand: isn't the event PaymentClaimable called for all payments? Meaning, even after the channel was opened paid successfully, if the user tries to receive something, we would fail here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if counterparty_skimmed_fee_msat > 0, or in other words only if the counterparty is skimming fees from the payment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this scenario means that the coordinator is trying to take extra fees from random payments after the JIT channel has already been created and the opening fee has been paid.

So the app should reject any payment that is taking extra fees arbitrarily. Perhaps eventually it would make sense to show this to the user, so that they can decide whether they want to pay for the special fee or not.

@bonomat
Copy link
Contributor

bonomat commented Oct 26, 2023

Unrelated minor fixes that could get separated into a single PRs.

* [43d4999](https://github.com/get10101/10101/commit/43d49997f0b31ac2958398d7bf90492e8d365c0c): The app does not need to maintain a pending intercepted htlc map.

* [97f8db4](https://github.com/get10101/10101/commit/97f8db4ad61bcd94b09a86eff71e97467510d8d3): We have to fail the payment backwards in case we do not get a pre-image

* [4af7474](https://github.com/get10101/10101/commit/4af7474602044b343783d7dd49689f0ad722085e): Add an argument to optionally do not truncate the provided value. fixes

You might want to top getting some of the fixes in separate PRs straight into main and not into the 116-upgrade. I assume 116 might take a bit longer to land.

Copy link
Contributor

@luckysori luckysori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

coordinator/src/node/storage.rs Outdated Show resolved Hide resolved
crates/ln-dlc-node/src/config.rs Show resolved Hide resolved
Comment on lines +110 to +112
/// If the payment was used to open an inbound channel, this tx id refers the funding
/// transaction for opening the channel.
pub funding_txid: Option<Txid>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 Perhaps not worth it here, but it's nice to think about ways to avoid optional fields.

For instance, we could extend the PaymentFlow enum to something like:

enum PaymentType {
    Inbound,
    Outbound,
    Funding {
        funding_txid: Txid,
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opted to not do the change as it became too big of a change very quickly :/

crates/ln-dlc-node/src/ln/app_event_handler.rs Outdated Show resolved Hide resolved
crates/ln-dlc-node/src/ln/app_event_handler.rs Outdated Show resolved Hide resolved
crates/ln-dlc-node/src/ln/app_event_handler.rs Outdated Show resolved Hide resolved
crates/ln-dlc-node/src/ln/app_event_handler.rs Outdated Show resolved Hide resolved
@@ -33,10 +33,12 @@ async fn ln_collab_close() {
.await
.unwrap();

let fee_sats = 10_000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Should this not come from the liquidity options or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically you are right, but on these tests we do not know about the liquidity options. This is only known on the application layer of the coordinator and the app. I am using a little hack to inject the fees in the liquidity request, but for that I have to do it manually.

see also https://github.com/get10101/10101/pull/1528/files#diff-a6f251cebbb64254ec28d79e916edc0275557625800fae9588e2cdc2598a545dR270-L276

@luckysori luckysori force-pushed the chore/upgrade-to-rust-lightning-116 branch 3 times, most recently from aa6fe70 to 32a9226 Compare November 1, 2023 15:00
@holzeis holzeis force-pushed the feat/jit-channel-fee-lsp-flow branch 3 times, most recently from 9d0c54b to 2e19e87 Compare November 3, 2023 06:47
@luckysori luckysori force-pushed the chore/upgrade-to-rust-lightning-116 branch from 32a9226 to 8ef9415 Compare November 3, 2023 10:23
@holzeis holzeis force-pushed the feat/jit-channel-fee-lsp-flow branch from 2e19e87 to dd8812b Compare November 3, 2023 10:24
@luckysori luckysori force-pushed the chore/upgrade-to-rust-lightning-116 branch from 8ef9415 to 247a892 Compare November 3, 2023 11:07
@holzeis holzeis force-pushed the feat/jit-channel-fee-lsp-flow branch from dd8812b to 82d89a3 Compare November 3, 2023 11:08
Base automatically changed from chore/upgrade-to-rust-lightning-116 to main November 3, 2023 11:57
IF EXISTS does not exist on sql lite. I stumbled upon that issue when trying to rerun all sql migration scripts on the app.
@holzeis holzeis force-pushed the feat/jit-channel-fee-lsp-flow branch from 82d89a3 to f71d546 Compare November 3, 2023 13:02
@holzeis holzeis enabled auto-merge November 3, 2023 13:03
@holzeis holzeis added this pull request to the merge queue Nov 3, 2023
Merged via the queue into main with commit ce33f34 Nov 3, 2023
8 checks passed
@holzeis holzeis deleted the feat/jit-channel-fee-lsp-flow branch November 3, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants